/*
 * Created by SharpDevelop.
 * User: Carlos
 * Date: 20/06/2009
 * Time: 04:46 p.m.
 */
using Lambda.Data.Common;
using System.Collections.Generic;
namespace Lambda.Data.DTO
{
	/// <summary>
	/// DataTransferObject. Objeto de transferencia de datos
	/// </summary>
	public class DataTransferObject{
		#region Fields
			private DTOFieldList fields;
		#endregion
		#region Properties
			#region Public
				public object this[string index]{ 
					get{ return Fields[index].Value; }
				}
				public bool HasFields{ 
					get{ return Fields.HasItems; }
				}
				public virtual bool ValidateOnAssign{ 
					get{ return true; }
				}
			#endregion
			#region Protected
				private DTOFieldList Fields{
					get{ return fields;	}
				}
			#endregion
		#endregion
		#region Constructors
			public DataTransferObject(){
				fields = new DTOFieldList(this);
			}
		#endregion
		#region Methods
			protected void AddDataColumn(DTOField Field){
				Fields.Add(Field);
			}
			protected void RemoveDataColumn(DTOField Field){
				Fields.Remove(Field);
			}
			public bool ContainsDataColumn(string FieldName){
				return Fields.Exists(FieldName);
			}
			public FieldValidationResultList Validate(){
				return Fields.Validate();
			}
			public DBType GetType(string FieldName){
				return Fields[FieldName].Type;
			}
		#endregion
	}
}
